﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Skyhook.Core;

namespace Skyhook.Logic.VisualControllers
{
    class AnimationVisualController
    {
        IVisualObject Sprite = null;
        
        int pDirection = 0;
        int CurrentFrame = 0;
        int CurrentFramesCount = 0;

        public AnimationVisualController(string assetname, IVisualObject sprite)
        {
            Sprite = sprite;
            CurrentFramesCount = Sprite.GetNumberEntitiesInGroup(pDirection);
            Sprite.ShowGroups(pDirection);
            Sprite.SetGroupsCurrentEntity(CurrentFrame, pDirection);
        }

        public int Direction
        {
            set
            {
                if (value < 0 || value >= Sprite.GroupsCount)
                {
                    return;
                }
                if (pDirection != value)
                {
                    pDirection = value;
                    CurrentFrame = 0;
                    CurrentFramesCount = Sprite.GetNumberEntitiesInGroup(pDirection);
                    Sprite.SetGroupsCurrentEntity(CurrentFrame, pDirection);
                    Sprite.ShowGroups(pDirection);
                }
            }
            get
            {
                return pDirection;
            }
        }

        public int FramesCount
        {
            get
            {
                return CurrentFramesCount;
            }
        }

        public int Frame
        {
            set
            {
                CurrentFrame = value;
                Sprite.SetGroupsCurrentEntity(CurrentFrame, pDirection);
            }
        }
    }
}
